﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using AcctrueWMS.Foundation.DAL;
namespace AcctrueWMS.Web
{
    /// <summary>
    /// 项目状态变更异步处理
    /// </summary>
    public partial class ProjectStateChange : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["type"] != null) {

                Response.Write(ProjectStateChangeLogOfUpdateExec());
                Response.End();
            }
        }

        /// <summary>
        ///执行操作1 修改实施项目时的状态变更日志
        /// </summary>
        /// <returns></returns>
        private string ProjectStateChangeLogOfUpdateExec()
        {
            string sql = "insert projectStateChangeLog(projectGUID, changeBefore,changeAfter,changeTime, executor) values('" + Request.Form["projectGUID"] + "',@changeBefore,@changeAfter,default,@executor)";
            SqlParameter[] pars = { 
                                 new SqlParameter("@changeBefore",SqlDbType.NVarChar,50),
                                  new SqlParameter("@changeAfter",SqlDbType.NVarChar,50),
                                 new SqlParameter("@executor",SqlDbType.NVarChar,50)
                                 };
            pars[0].Value = Request.Form["state1"];
            pars[1].Value = Request.Form["state2"];
            pars[2].Value=Session["userNo"].ToString();
            try
            {
                int num = WMSqlExcuter.ExecuteNonQuery(sql, CommandType.Text, pars);
                if (num > 0) { return "true"; } else { return "false"; }
            }
            catch (SqlException ex)
            {

                return "false";
            }
        }

       
    }
}